﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using HPIT_Library;
using HPIT_Library_Modal;

namespace HPIT_Library_DAL
{
   public class categorySerivers
    {
        /// <summary>
        /// 查询分类
        /// </summary>
        /// <returns></returns>
        public static DataTable Select()
        {
            string sql = "select * from [category]";
            return DbHelper.ExecuteTable(sql);
        }
        public static DataTable SelectName()
        {
            string sql = "select categoryName from [category]";
            return DbHelper.ExecuteTable(sql);
        }
        public static int Insert(string CategoryName)
        {
            //定义插入sql语句
            string sql = "insert into category values(@CategoryName)";
            SqlParameter[] pams = {
                new SqlParameter("@CategoryName",CategoryName),
            };
            int num= DbHelper.ExecuteNonQuery(sql, pams);
            return num;
        }
        public static int Delete(int CategoryId)
        {
            //定义插入sql语句
            string sql = "delete from  category where CategoryId=@CategoryId";
            SqlParameter[] pams = {
                new SqlParameter("@CategoryId",CategoryId),
            };
            int num = DbHelper.ExecuteNonQuery(sql, pams);
            return num;
        }
    }
}
